﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExampleFeed
{
    class FeedArgs
    {
        public string food = "";

    }

    class Master
    {
        public event EventHandler<FeedArgs> OnFeed;

        public void FeedAnimals(string food)
        {
            if (OnFeed != null)
            {
                FeedArgs feedArgs = new FeedArgs();
                feedArgs.food = food;
                OnFeed(this, feedArgs);
            }
        }

    }

    class Dog
    {
        public void Eat(object sender, FeedArgs args)
        {
            Console.WriteLine("dog:" + args.food);
        }

    }

    class Cat
    {
        public void Eat(object sender, FeedArgs args)
        {
            Console.WriteLine("cat:" + args.food);
        }

    }

    class Panda
    {
        public void Eat(object sender, FeedArgs args)
        {
            Console.WriteLine("Panda:" + args.food);
        }

    }



    class Program
    {
        static void Main(string[] args)
        {
            Master master = new Master();
            Dog dog = new Dog();
            Cat cat = new Cat();
            Panda panda = new Panda();

            master.OnFeed += dog.Eat;
            master.OnFeed += cat.Eat;
            master.OnFeed += panda.Eat;


            //FeedArgs feedArgs = new FeedArgs();
            //feedArgs.food = "3333";
            master.FeedAnimals("444444");
        }

    }
}
